﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class ucDateTime : SERP.Modules.ModuleBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (dt.Text.Trim() == "")
            dt.Text = DateTime.Now.ToString("dd/MM/yyyy");
    }
    public Unit Width
    {
        get
        {
            return dt.Width;
        }
        set
        {
            dt.Width = value;
        }
    }
    public Unit Height
    {
        get
        {
            return dt.Height;
        }
        set
        {
            dt.Height = value;
        }
    }
    public DateTime? SelectedDate
    {
        get
        {
            try
            {
                DateTime date = DateTime.Now;
                DateTime.TryParseExact(dt.Text.Trim(), "%d/%M/yyyy", null, System.Globalization.DateTimeStyles.None, out date);
                return date;
            }
            catch
            {
                return null;
            }
        }
        set
        {
            if (value.HasValue)
            {
                dt.Text = value.Value.ToString("dd/MM/yyyy");
            }
            else
            {
                dt.Text = DateTime.Now.ToString("dd/MM/yyyy");
            }
        }
    }
}
